﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    public class DonViTinhBUS
    {
        public static List<DonViTinhDTO> Danhsach()
        {
            List<DonViTinhDTO> lst = null;
            DataTable dt = DonViTinhDAO.Danhsach();
            if (dt != null)
            {
                lst = new List<DonViTinhDTO>();
                foreach (DataRow dr in dt.Rows)
                {
                    DonViTinhDTO dv = new DonViTinhDTO();
                    dv.Madv = int.Parse(dr["MADONVI"].ToString());
                    dv.Tendv = dr["TENDONVI"].ToString();
                    lst.Add(dv);

                }
            }
            return lst;
        }
        public static string TenDV(int madv)
        {
            string ten = "";
            DataTable dt = DonViTinhDAO.TenDV(madv);
            if (dt != null)
            {
                ten = dt.Rows[0]["TENDONVI"].ToString();
            }
            return ten;
        }

    }
}
